import { Injectable } from '@nestjs/common';
import { CreateStageEventDto } from './dto/create-stage-event.dto';
import { UpdateStageEventDto } from './dto/update-stage-event.dto';
import { StageEvent } from './entities/stage-event.entity';
import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';

@Injectable()
export class StageEventService {
  constructor(
    @InjectRepository(StageEvent)
    private repository: Repository<StageEvent>,
  ) {}
  create(createStageEventDto: CreateStageEventDto) {
    return 'This action adds a new stageEvent';
  }

  findAll() {
    return `This action returns all stageEvent`;
  }

  findOne(id: number) {
    return `This action returns a #${id} stageEvent`;
  }

  update(id: number, updateStageEventDto: UpdateStageEventDto) {
    return `This action updates a #${id} stageEvent`;
  }

  remove(id: number){
    return this.removeIds([id]);
  }

  removeIds(ids: number[]) {
    this.repository.delete(ids);
  }

  findByStageId(stageId: number) {
    return this.repository.find({
      where: { stageId },
    });
  }
  saveList(list: StageEvent[]) {
    return this.repository.save(list);
  }
}
